package com.heima.user.controller.v1;


import com.heima.common.dtos.PageResult;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AuthDto;
import com.heima.model.user.dtos.UserAuthDto;
import com.heima.user.service.ApUserAuthService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户审核
 */
@RestController
@RequestMapping("/api/v1/auth")
@Api(tags = "用户审核管理")
public class UserAuthController {

    @Autowired
    private ApUserAuthService apUserAuthService;

    /**
     * 分页查询用户审核信息
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public PageResult<UserAuthDto> list(@RequestBody AuthDto dto){
        return apUserAuthService.findByPage(dto);
    }

    /**
     * 审核通过
     */
    @PostMapping("/authPass")
    public ResponseResult authPass(@RequestBody AuthDto dto){
        //设置状态 通过
        dto.setStatus(9);
        apUserAuthService.doAuth(dto);
        return ResponseResult.ok();
    }

    /**
     * 审核不通过
     */
    @PostMapping("/authFail")
    public ResponseResult authFail(@RequestBody AuthDto dto){
        //设置状态 不通过
        dto.setStatus(2);
        apUserAuthService.doAuth(dto);
        return ResponseResult.ok();
    }

}
